package view.character
{
	import config.CharacterStatusType;
	import config.Lang;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	import model.Character;
	
	import util.Image;
	
	public class CharacterInfoBar extends Sprite
	{
		public var nameTxt:TextField;
		public var coinTxt:TextField;
		
		public var statusTxt:TextField;
		private var _photo:Image;
		
		private var _ui:*;
		
		private var _expBar:CharacterExpBar;
		
		private var _data:Character;
		
		public function CharacterInfoBar(position:int=0){
			_photo = new Image;
			
			if (position != 0){
				_ui = new UIInfoTBar;
				_expBar = new CharacterExpBar;
				_expBar.x = 6;
				_expBar.y = 18;
				_photo.x = 450;
				_photo.y = -50;
				_photo.source = "images/06.png";
			}
			else{
				_ui = new UIInfoBBar;
				_expBar = new CharacterExpBar;
				_expBar.x = 217;
				_expBar.y = 18;
				_photo.x = -30;
				_photo.y = -80;
				_photo.source = "images/05.png";
			}
			
			_ui.addChild(_expBar);
			addChild(_ui);
			addChild(_photo);
		}
		
		public function set data(value:Character):void{
			_data = value;
			_ui.nameTxt.text = (_data.nickname != "")?_data.nickname:"11111";
			_ui.coinTxt.text = String(_data.coin);
			_expBar.setExp(_data.score, _data.totalScore);
			_photo.source = _data.url;
		}
		
		public function set status(value:int):void{
			switch(value){
				case CharacterStatusType.WAIT:{
					statusTxt.text = Lang.CharacterNotReady;
					break;
				}
				case CharacterStatusType.READY:{
					statusTxt.text = Lang.CharacterReady;
					break;
				}
			}
		}
	}
}